package me.xplabs.battle.buff 
{
	import me.xplabs.Globals;
	import me.xplabs.interfaces.IObjectMatrix;
	import me.xplabs.model.combatunit.BaseBuff;
	import me.xplabs.model.msg.MsgHitActor;
	import me.xplabs.msg.NotificationFight;
	import me.xplabs.msg.NotificationName;
	/**
	 * ...
	 * @author xiaohan
	 */
	public class Buff extends BaseBuff implements IObjectMatrix
	{
		private var _soleId:int;
		public var finishCall:Function;
		
		public var hitCall:Function;
		public var now:uint;
		private var _total:uint;
		private var _curTime:uint;
		private var _timeKey:int;
		private var _curPosX:int;
		private var _curPosY:int;
		private var _angle:int;
		public function Buff() 
		{
			_timeKey = -1;
		}
		
		
		public function heartbeat(p_gap:uint):void
		{
			
		}
		public function startTime():void
		{
			if (gap == 0)
			{
				_timeKey = Globals.suspendTime.addTimePiece(1, null, time, finishHandler);
			}else
			{
				_timeKey = Globals.suspendTime.addTimePiece(gap, hitHandler, int(time / gap), finishHandler);
			}
		}
		
		private function finishHandler(pkey:int):void 
		{
			if (finishCall != null)
			{
				finishCall(this);
			}
			_timeKey = -1;
		}
		
		private function hitHandler():void 
		{
			//print("收到buff伤害效果");
			if (hitCall != null)
			{
				hitCall(this);
			}
		}
		public function stopTime():void
		{
			if (_timeKey != -1)
			{
				Globals.suspendTime.removeTimePiece(_timeKey);
				_timeKey = -1;
			}
		}
		public function dispose():void
		{
			stopTime();
			finishCall = null;
			_total = 0;
			_curTime = 0;
			hitCall = null;
		}
		
		/* INTERFACE me.xplabs.interfaces.IObjectMatrix */
		
		public function get curPosX():Number 
		{
			return _curPosX;
		}
		
		public function set curPosX(value:Number):void 
		{
			_curPosX = value;
		}
		
		public function get curPosY():Number 
		{
			return _curPosY;
		}
		
		public function set curPosY(value:Number):void 
		{
			_curPosY = value;
		}
		
		public function get angle():Number 
		{
			return _angle;
		}
		
		public function set angle(value:Number):void 
		{
			_angle = value;
		}
		
		public function get total():uint 
		{
			return _total;
		}
		
		public function set total(value:uint):void 
		{
			_total = value * 1000;
		}
		
		public function get soleId():int 
		{
			return _soleId;
		}
		
		public function set soleId(value:int):void 
		{
			_soleId = value;
		}
	}
}